package server;

public abstract class HttpServlet implements Servlet{


    public abstract String doGet(Request request, Response response);

    public abstract String doPost(Request request,Response response);


    @Override
    public void service(Request request, Response response) throws Exception {
        String o;
        if("GET".equalsIgnoreCase(request.getMethod())) {
            o = doGet(request,response);
        }else{
            o = doPost(request,response);
        }

        response.output((HttpProtocolUtil.getHttpHeader200(o.getBytes().length) + o));

    }

    @Override
    public void init() throws Exception {

    }

    @Override
    public void destory() throws Exception {

    }
}
